namespace designpatternsplusplus.decorator.DecoratorParticipants
{
    #region

    using System;
    using designpatternsplus.contracts;

    #endregion

    /// <summary>
    /// Another example. Actually the only item we care about
    /// is the expression.. These would be best 
    /// served via external configuration and 
    /// serialized expression semantics
    /// </summary>
    public sealed class DelegateDecorator : SellableItemDecoratorBase
    {
        const int round_currency = 2;

        /// <summary>
        /// Initializes a new instance of the <see cref="DelegateDecorator"/> class.
        /// </summary>
        /// <param name="resolveProduct">The resolve product.</param>
        /// <param name="DelegateType">Type of the delegate.</param>
        /// <param name="?">The ?.</param>
        public DelegateDecorator
            (IProductService resolveProduct,
             AbstractKeyedDelegate<string, IProductService, double> DelegateType)
            : base(resolveProduct, DelegateType.DelegateExec) {}

        /// <summary>
        /// Amounts this instance.
        /// </summary>
        /// <returns></returns>
        public override double Amount()
        {
            return Math.Round
                (_ProductDecorated.Amount() + decoratorDelegate(_ProductDecorated),
                 round_currency);
        }
    }
}